package com.admin.testproject.adapter

import android.content.Context
import android.content.Intent
import android.widget.ImageView
import com.admin.testproject.R
import com.admin.testproject.activity.AnimActivity
import com.admin.testproject.activity.CollActivity
import com.admin.testproject.activity.TestActivity

/**
 * author 吴昶
 * date 2019/5/30
 * 标注
 */
class MainAdapter (context: Context): RecycleBaseAdapter<Int>(context){
    override fun getItemLayout(position: Int): Int {
        return R.layout.layout_item
    }

    override fun initData(viewHolder: BaseViewHolder?, item: Int?, position: Int) {
        viewHolder?.getView<ImageView>(R.id.iv_item)!!.setImageResource(item!!)
        viewHolder.getView<ImageView>(R.id.iv_item)!!.setOnClickListener {
            when(position){
                1->{
                    val intent= Intent(context, CollActivity::class.java)
                    context.startActivity(intent)
                }
                2->{
                    val intent= Intent(context, AnimActivity::class.java)
                    context.startActivity(intent)
                }
                3->{
                    val intent= Intent(context, TestActivity::class.java)
                    context.startActivity(intent)
                }
            }
        }
    }

}